<?php
/**
 * sh404SEF support for com_igallery (Ignite Gallery) component v2.7
 * Copyright Matthew Thomson - 2010
 * GPLv2
 * ignitejoomlaextensions.com
 */
 
defined( '_JEXEC' ) or die( 'Direct Access to this location is not allowed.' );

// ------------------  standard plugin initialize function - don't change ---------------------------
global $sh_LANG, $sefConfig;  
$shLangName = '';
$shLangIso = '';
$title = array();
$shItemidString = '';
$dosef = shInitializePlugin( $lang, $shLangName, $shLangIso, $option);
if ($dosef == false) return;
// ------------------  standard plugin initialize function - don't change ---------------------------

$titlesArray = array();

if(!empty($id)) 
{
	if(isset($view))
	{
		if($view == 'igcategory')	
		{
			$query = 'SELECT name, alias, parent FROM #__igallery WHERE id = '.(int)$id;
			$database->setQuery($query);
			$row = $database->loadObject();
			$titlesArray[] = $row->alias;
			
            if( !empty($Itemid) )
            {
                global $mainframe;
                $menu = $mainframe->getMenu();
                $active = $menu->getActive();
                $itemIdCatId = isset($active->query['id']) ? isset($active->query['id']) : 0;
            }
            else
    		{
    		    $itemIdCatId = 0;
    		}
			
			while($row->parent != 0)
			{
				$query = 'SELECT name, alias, parent FROM #__igallery WHERE id = '.(int)$row->parent;
				$database->setQuery($query);
				$row = $database->loadObject();
				
				array_unshift($titlesArray, $row->alias);
			}
			
			for($i=0; $i<count($titlesArray); $i++)
			{
				$title[] = $titlesArray[$i];
			}
			
			if(!isset($task))
			{
			    $task = '';
			}
			
			if(!empty($option))
			{
				shRemoveFromGETVarsList('option');
			}
			
			if(!empty($Itemid))
			{
				shRemoveFromGETVarsList('Itemid');
			}
			
			if(!empty($lang))
			{
				shRemoveFromGETVarsList('lang');
			}
			
			if (!empty($id)) 
			{
				shRemoveFromGETVarsList('id');
			}
			
			if(!empty($view))
			{
				shRemoveFromGETVarsList('view');
			}
			
			if(!empty($task))
			{
				shRemoveFromGETVarsList('task');
			}
		}
	}
}



// ------------------  standard plugin finalize function - don't change ---------------------------  
if ($dosef){
   $string = shFinalizePlugin( $string, $title, $shAppendString, $shItemidString, 
      (isset($limit) ? @$limit : null), (isset($limitstart) ? @$limitstart : null), 
      (isset($shLangName) ? @$shLangName : null));
}      
// ------------------  standard plugin finalize function - don't change ---------------------------

?>